cd "/Users/gaborsimonovits/Dropbox/onkori audit/psrm/replication"

log using "munilog.log"
use "data_raw.dta", clear


** Drop late responses

gen days_passed= minutes_passed/(24*60)
replace r=0 if days_passed>15

** Recode predictors

recode opened_tasz (.=0)

gen followed_up=ping=="True"

tab eth, g(rr)
renvars  rr1 rr2 / roma white

tab gender, g(g)
renvars g1 g2 /female male

tab req, g(req)
 renvars req1 req2 req3 req4 / camping cemetary nursery wedding

gen w2=wave-1
 
gen treated=tasz=="treatment"

** Interaction

gen treated_roma= treated*roma
gen treated_w2 =treated*w2
gen roma_w2= roma*w2
gen treated_roma_w2= treated*roma*w2


** Timing

gen t=substr(sent, 1,10)
split t, parse(-)
drop t
destring t2 t3, replace
destring t1, replace
gen sent_date = mdy(t2, t3, 2020)
gen intervention_date = mdy(6, 26, 2020)
gen t= sent_date-intervention_date

** Format

egen id=group(municipality)
xtset id wave

** Table OA1

tab help_p help_m
tab polite_p polite_m
 
gen polite=polite_m+polite_p
gen help=help_m+help_p

replace polite=polite/0.06
replace help=help/0.06 
recode help (.=0)

gen help_narrow=help
replace help_narrow=. if polite==.

egen nr=sum(r/100), by (id)

 
 drop formated_town subject sender_name help_p polite_p help_m polite_m body resp_sender minutes_passed same_address ping  t1 t2 t3 sent_date intervention_date camping male

label variable index "Observation ID"
label variable id "Municipality ID"

label variable town "Name of town"
label variable municipality "Name of local government"
label variable muni_type "Type of local government"
label variable countyx "County"
label variable number_of_towns "# of towns served by local government"
label variable wave "Wave"
label variable email "Email of local gov."
label variable request "Type of request"
label variable ethnicity "Ethnicity treatment"
label variable pop "Population of towns served by local gov."
label variable block "Pre-treatment blocks"
label variable tasz "HCLU intervention"
label variable opened_tasz "HCLU intervention recieved"

label variable gender "Gender of sender"
label variable email_from "Sender email"
label variable status "Email status"
label variable day "Day request sent"
label variable sent_time "Time request sent"
label variable response "Response to request"
label variable resp_date "Time response recieved"

label variable followed_up "Follow-up planned"
label variable ping_sent "Follow-up sent"
label variable bounced "Request email bounced"
label variable days_passed "Days between request and response"
label variable polite  "Politeness of response"
label variable help "Helpfulness of response"
label variable r "Response recieved"

label variable roma "Roma requester"
label variable female "Female requester"
label variable cemetary "Cemetary request"
label variable nursery "Nursery request"
label variable wedding "Wedding request"
label variable w2 "Second wave"
label variable treated "HCLU treatment"

label variable treated_roma "HCLU treatment X Roma interaction"
label variable treated_w2 "HCLU treatment X wave 2 interaction"  
label variable roma_w2 "Roma X wave 2 interaction"  
label variable treated_roma_w2 "HCLU treatment X Roma X wave 2 interaction"  

label variable t "days between intervention and request"  

label variable nr "number of requests responded"  





order id town municipality muni_type countyx pop  number_of_towns block wave w2  email index  tasz treated opened  request  cemetary nursery wedding ethnicity gender email_from day sent_time  treated_roma treated_w2 roma_w2 treated_roma_w2 t ping_sent followed_up status response resp_date bounced r help polite days_passed 




** Basline discrimination (main)


table white,  stat(mean r  help  help_narrow  polite)

table white if (nr == 2),  stat(mean r  help  help_narrow  polite) 

xtreg r white female cemetary nursery wedding if treated==0, cl(id) fe
outreg2 using muni_disc.xls, dec(1) br  ci  noaster

xtreg help white female cemetary nursery wedding if treated==0, cl(id) fe
outreg2 using muni_disc.xls, dec(1) br ci  noaster append

heckman help_narrow white female cemetary nursery wedding if treated==0, select(foll)  cl(id)  
outreg2 using muni_disc.xls, dec(1)  br ci  noaster append

heckman polite white female cemetary nursery wedding if treated==0,  select(foll)  cl(id)
outreg2 using muni_disc.xls, dec(1)  br ci  noaster append


xtreg help_narrow white female cemetary nursery wedding if treated==0 & nr==2, cl(id) fe
outreg2 using muni_disc.xls, dec(1) br  ci  noaster

xtreg polite white female cemetary nursery wedding if treated==0 & nr==2, cl(id) fe
outreg2 using muni_disc.xls, dec(1) br ci  noaster append



** Figure 1

cibar r, over1 (roma ) over2 (treated )  over3 (wave ) barlabel(on) barc(gs10 gs6) bargap(7) 

** Treatment effects - short run (main)


** Control


areg r roma    female cemetary nursery wedding if w2==0 & treated==0 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  

areg help roma     female cemetary nursery wedding if w2==0 & treated==0, r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma    female cemetary nursery wedding i.block if w2==0 & treated==0, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma    female cemetary nursery wedding  i.block if w2==0& treated==0, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append


** Treated


areg r roma    female cemetary nursery wedding if w2==0 & treated==1 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  append

areg help roma     female cemetary nursery wedding if w2==0 & treated==1, r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma     female cemetary nursery wedding i.block if w2==0 & treated==1, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma     female cemetary nursery wedding  i.block if w2==0 & treated==1, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

** Treated vs. control


areg r roma treated treated_roma  female cemetary nursery wedding if w2==0 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  append

areg help roma  treated treated_roma  female cemetary nursery wedding if w2==0 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma  treated treated_roma  female cemetary nursery wedding i.block if w2==0 , two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma  treated treated_roma  female cemetary nursery wedding  i.block if w2==0, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

** Treatment effects - long run 

** Control


areg r roma    female cemetary nursery wedding if w2==1 & treated==0 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  append

areg help roma     female cemetary nursery wedding if w2==1 & treated==0, r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma     female cemetary nursery wedding i.block if w2==1 & treated==0, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma     female cemetary nursery wedding  i.block if w2==1& treated==0, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

** Treated 


areg r roma    female cemetary nursery wedding if w2==1 & treated==1 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  append

areg help roma     female cemetary nursery wedding if w2==1 & treated==1, r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma     female cemetary nursery wedding i.block if w2==1 & treated==1, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma     female cemetary nursery wedding  i.block if w2==1 & treated==1, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

** Treated vs. control


areg r roma treated treated_roma  female cemetary nursery wedding if w2==1 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br  append

areg help roma  treated treated_roma  female cemetary nursery wedding if w2==1 , r a(block)
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman help_narrow roma  treated treated_roma  female cemetary nursery wedding i.block if w2==1 , two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append

xi: heckman polite roma  treated treated_roma  female cemetary nursery wedding  i.block if w2==1, two select(foll)  
outreg2 using muni_treat_rob.xls, dec(1) br   append


*** Online Appendix




*** 2SLS

areg r roma treated treated_roma  female cemetary nursery wedding if w2==0 & treated==1 , r a(block)



 gen opened_tasz_roma= opened_tasz*roma
ivreg r roma female cemetary nursery wedding (opened_tasz opened_tasz_roma= treated treated_roma) if w2==0, r first
outreg2 using muni_iv.xls, dec(1) br  

ivreg help roma female cemetary nursery wedding (opened_tasz opened_tasz_roma= treated treated_roma) if w2==0, r first
outreg2 using muni_iv.xls, dec(1) br   append

ivreg r roma female cemetary nursery wedding (opened_tasz opened_tasz_roma= treated treated_roma) if w2==1, r first
outreg2 using muni_iv.xls, dec(1) br  append

ivreg help roma female cemetary nursery wedding (opened_tasz opened_tasz_roma= treated treated_roma) if w2==1, r first
outreg2 using muni_iv.xls, dec(1) br   append


log close




****


